package cloudUser.exception;

import cloudEntity.utils.ResultUtils;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @program: Smart School
 * @ClassName ExceptionHandler
 * @description: 全局异常捕获类 捕获 异常 的 重载
 * @author: 陈智博
 * @create: 2025-04-08 10:13
 * @Version 1.0
 **/
@ControllerAdvice
public class CustomerGlobalExceptionHandler {

    @ExceptionHandler(value = UserIsNullException.class)
    @ResponseBody
    public ResultUtils exceptionHandler(UserIsNullException e) {
        return ResultUtils.failed(e.getMessage());
    }

    @ExceptionHandler(value = BadCredentialsException.class)
    @ResponseBody
    public ResultUtils exceptionHandler(BadCredentialsException e)
    {
        return ResultUtils.failed("账号或密码错误");
    }

//    @ExceptionHandler(value = Exception.class)
//    @ResponseBody
//    public ResultUtils exceptionHandler(Exception e) {
//        return ResultUtils.failed(e.getMessage());
//    }

}
